package org.grottarossa.ui.core;

import com.vaadin.terminal.Sizeable;

/***
 * Rappresenta il modo in cui un campo deve essere rappresentato in una form
 * @author 
 *
 */
public class FormFieldProperties
{
	private FormFieldLocation m_location;
	private float m_widthValue;
	private int m_widthUnit;
	private float m_heightValue;
	private int m_heightUnit;
	private boolean m_widthSet;
	private boolean m_heightSet;
	private boolean m_required;
	private String m_customCaption;
	private boolean m_readonly;

	public FormFieldProperties(FormFieldLocation location)
	{
		m_location = location;
		m_widthValue = 100;
		m_widthUnit = Sizeable.UNITS_PERCENTAGE;
		m_heightValue = 100;
		m_heightUnit = Sizeable.UNITS_PERCENTAGE;
		m_required = false;
		m_customCaption = null;
		m_readonly = false;
		m_widthSet = true;
		m_heightSet = false;
	}

	public void setLocation(FormFieldLocation location)
	{
		this.m_location = location;
	}

	public FormFieldLocation getLocation()
	{
		return m_location;
	}

	public float getWidthValue()
	{
		return m_widthValue;
	}

	public void setWidth(float widthValue, int widthUnit)
	{
		this.m_widthValue = widthValue;
		this.m_widthUnit = widthUnit;
		m_widthSet = true;
	}

	public int getWidthUnit()
	{
		return m_widthUnit;
	}

	public void setRequired(boolean required)
	{
		this.m_required = required;
	}

	public boolean isRequired()
	{
		return m_required;
	}

	public void setCustomCaption(String customCaption)
	{
		this.m_customCaption = customCaption;
	}

	public String getCustomCaption()
	{
		return m_customCaption;
	}

	public void setReadonly(boolean readonly)
	{
		this.m_readonly = readonly;
	}

	public boolean isReadonly()
	{
		return m_readonly;
	}

	public void setSizeFull(boolean sizeFull)
	{
		setWidth(100, Sizeable.UNITS_PERCENTAGE);
		setHeight(100, Sizeable.UNITS_PERCENTAGE);
		m_widthSet = true;
		m_heightSet = true;
	}

	public float getHeightValue()
	{
		return m_heightValue;
	}

	public void setHeight(float heightValue, int heightUnit)
	{
		this.m_heightUnit = heightUnit;
		this.m_heightValue = heightValue;
		m_heightSet = true;
	}

	public int getHeightUnit()
	{
		return m_heightUnit;
	}

	public boolean isWidthSet()
	{
		return m_widthSet;
	}

	public boolean isHeightSet()
	{
		return m_heightSet;
	}
}
